<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="html"/>

  <!-- the main template -->
  <xsl:template match="/">
    <HTML>
      <HEAD>
        <LINK rel="stylesheet" href="print_item_list.css" type="text/css" media="all"/>
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <TITLE>Movie List</TITLE>
      </HEAD>
      <BODY>
        <table>
          <th valign="top">
            <xsl:value-of select="/movies/metadata/field[@name='title']/@label"/>
          </th>
          <th valign="top">
            <xsl:value-of select="/movies/metadata/field[@name='director']/@label"/>
          </th>
          <th valign="top">
            <xsl:value-of select="/movies/metadata/field[@name='year']/@label"/>
          </th>
          <th valign="top">
            <xsl:value-of select="/movies/metadata/field[@name='genres']/@label"/>
          </th>
          <xsl:apply-templates/>
        </table>
      </BODY>
    </HTML>
  </xsl:template>

  <xsl:template match="movieInfo">

    <tr>
      <xsl:if test="position() mod 2 = 0">
        <xsl:attribute name="class">shading</xsl:attribute>
      </xsl:if>

      <td valign="top">
        <xsl:value-of select="title"/>
      </td>

      <td valign="top">
        <xsl:value-of select="director"/>
      </td>

      <td valign="top">
        <xsl:value-of select="year"/>
      </td>

      <td valign="top">
        <xsl:for-each select="genres/genre">
          <xsl:value-of select="node()"/>
          <xsl:if test="position()!=last()">; </xsl:if>
        </xsl:for-each>
      </td>

    </tr>

  </xsl:template>
</xsl:stylesheet>

